<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>立项策划新增</title>
</head>
<style>
	.fieldset{
		margin-top: 5px;
		margin-bottom: 0px
	}
	.layui-legend{
		background-color:#5fb878;
		font-size:15px !important;
		width:140px;
	}
	.layui-form-item {
	    margin-bottom: 5px;
	    clear: both;
	    *zoom: 1;
	}
	.layui-form-label{width: 180px;}
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
	    <div class="layui-tab-item layui-show">
	    	<div style="padding-top:15px;">&nbsp;</div>
			<form class="layui-form" id="addInfo_form">
				  <div style="margin-top:20px">
				  	<div class="layui-form-item">
						<div class="layui-inline">
					    	<label class="layui-form-label">项目名称</label>
				      		<div class="layui-input-inline">
								<input type="hidden" name="id" value="${proPlot.id}">
								<input type="text"  name="proName" value="${proPlot.proName}" style="border:0px;" readonly="readonly" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">项目类型</label>
				      		<div class="layui-input-inline">
								<select name="types" disabled>
									<option value="1" <c:if test="${track.types=='1'}">selected="selected"</c:if>>PPP项目</option>
									<option value="2"  <c:if test="${track.types=='2'}">selected="selected"</c:if>>EPC项目</option>
								</select>
				      		</div>
					    </div>

					</div>
					<div style="margin-top:12px"></div>

					  <div class="layui-form-item">
						  <div class="layui-inline">
							  <label class="layui-form-label">项目编号</label>
							  <div class="layui-input-inline">
									  <input type="text"  name="proCode" value="${proPlot.proCode}" style="border:0px;" readonly="readonly" class="layui-input">
								  </select>
							  </div>
						  </div>
						  <div class="layui-inline">
							  <label class="layui-form-label">申请部门</label>
							  <div class="layui-input-inline">
								  <input type="hidden" name="hrDeptId" value="${proPlot.hrDeptId}">
								  <input type="text" value="${proPlot.deptName}" style="border:0px;" readonly="readonly" class="layui-input">
							  </div>
						  </div>
					  </div>
				  	<div class="layui-form-item">
				  		<div class="layui-inline">
					      	<label class="layui-form-label">申请公司</label>
					      	<div class="layui-input-inline">
								<input type="hidden" name="hrOrgId" value="${proPlot.hrOrgId}">
								<input type="text" value="${proPlot.orgName}" style="border:0px;width:220px" readonly="readonly" class="layui-input">
					      	</div>
					    </div>

					    <div class="layui-inline">
					    	<label class="layui-form-label">申请人</label>
				      		<div class="layui-input-inline">
				        		<input type="hidden" name="hrStaffApplyId" value="${proPlot.hrStaffApplyId }">
				        		<input type="text" name="staffName" value="${proPlot.staffName }" readonly="readonly" style="border:0px" autocomplete="off" class="layui-input">
				      		</div>
					    </div>
					</div>
					<div style="margin-top:12px"></div>
			  		<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">风险规避建议</label>
				      		<div class="layui-input-inline">
					      		<textarea name="riskAdvice" maxlength="500" placeholder="请输入风险规避建议" lay-verify="required" class="layui-textarea" style="width:899px;height:90px;">${proPlot.riskAdvice}</textarea>
				      		</div>
					    </div>
				    </div>
				    <div style="margin-top:12px"></div>
			  		<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">边界条件</label>
				      		<div class="layui-input-inline">
					      		<textarea name="adjustment" maxlength="500" placeholder="请输入边界条件调整方向" lay-verify="required" class="layui-textarea" style="width:899px;height:90px;">${proPlot.adjustment}</textarea>
				      		</div>
					    </div>
				    </div>
				    <div style="margin-top:12px"></div>
			  		<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">项目合规性</label>
				      		<div class="layui-input-inline">
					      		<textarea name="proGrc" maxlength="500" placeholder="请输入项目合规性" lay-verify="required" class="layui-textarea" style="width:899px;height:90px;">${proPlot.proGrc}</textarea>
				      		</div>
					    </div>
				    </div>

				    <div style="margin-top:12px"></div>
				  	<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">融资可行性</label>
				      		<div class="layui-input-inline">
					      		<textarea name="finWorkable" maxlength="500" placeholder="请输入融资可行性" lay-verify="required" class="layui-textarea" style="width:899px;height:90px;">${proPlot.finWorkable}</textarea>
				      		</div>
					    </div>
				    </div>
					  <div style="margin-top:12px"></div>
					  <div class="layui-form-item">
						  <div class="layui-inline">
							  <label class="layui-form-label">联合体</label>
							  <div class="layui-input-inline">
								  <textarea name="consortium" maxlength="500" placeholder="请输入项目合规性" lay-verify="required" class="layui-textarea" style="width:899px;height:90px;">${proPlot.consortium}</textarea>
							  </div>
						  </div>
					  </div>
				  </div>
				  <div class="layui-form-item" style="position: fixed ! important; right: 30px; top:4%;z-index:10000;">
					  <c:if test="${proPlot.processStatus=='0'}">
						  <div class="layui-input-block" >
							  <input type="hidden" name="submitType" id="submitType">
							  <button type="button" type="button" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="addInfo_form_submit" id="addInfo_form_submit2">保存</button>
							  <button type="button" type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="addInfo_form_submit" id="addInfo_form_submit">提交</button>
						  </div>
					  </c:if>

			      </div>
			</form>
  		</div>
	</div>
</div>
  <script>

  layui.config({
    base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set', 'upload', 'element', 'laydate'], function(){
    var $ = layui.$
    ,form = layui.form
    ,element = layui.element
    ,laydate = layui.laydate
    ,upload = layui.upload;

 	// 正则校验
	form.verify({
		//验证汉字
	    CHS:[
	    	/^[\u0391-\uFFE5]+$/
	    	,'只能输入汉字'
	  	],
	  	//大于0的正整数
	  	intNumber:[
			/^[1-9]\d*$/
			,'请输入正确的数字'
	  	],
	  	//数字只能有两位小数
	  	floatNumber:[
			/^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
			,'请输入正确的数字'
	  	],
	  	//数字大于等于0，并只能有两位小数
	  	floatAmount:[
			/^([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
			//var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/;
			,'请输入正确的数字'
	  	]
	});
	//项目名称select监听
    form.on('select(add_select_proId)', function(data){
    	var id = data.value;
    	$('#query-select-proId').html('');
    	getProPlotProId(id);
    });
   	//监听提交
  	form.on('submit(addInfo_form_submit)', function(data){
		var btnId=data.elem.id
		$("#"+btnId).removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
		if(btnId=='addInfo_form_submit'){
			$("#submitType").val('2');
		}else{
			$("#submitType").val('1');
		}
		layer.load();
		var url='/proPlot/save';
		if(data.field.id&&data.field.id!=''){
			url='/proPlot/edit';
		}
       	//提交 Ajax 成功后，静态更新表格中的数据
       	$.ajax({
           	type : 'post',
			url : basePath + url,
           	data: $('#addInfo_form').serialize(),
			success:function(result){
				if(result.success){
					layer.closeAll('loading'); //关闭loading
					layer.msg('提交单据成功~',{icon: 1});
					//两秒后关闭当前页面
					setTimeout(function(){
						/**
						 * 查找父菜单，并刷新
						 */
						var topDoc = $(window.top.document);
						var path = basePath + '/proPlot/list';
						// 获取页面名称
						var name = topDoc.find(".layui-nav-item [lay-href^='" + path + "']").text();
						if(name == '' || name == null){
							name = '立项策划';
						}
						window.parent.layui.index.openTabsPage(path, name);
						var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
						iframe[0].contentWindow.location.reload(true);

						/**
						 * 关闭当前页
						 */
						var currPath = basePath + '/proPlot/toDetail';
						var layid = topDoc.find("li[lay-id^='" + currPath + "']").attr('lay-id');
						window.parent.layui.element.tabDelete('layadmin-layout-tabs', layid);//关闭当前页
				        }, 2000);
				}else{
					layer.closeAll('loading'); //关闭loading
  					$("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
					layer.msg(result.msg,{icon: 7});
			  	}
			}
       	});
   	});
 	// data-type事件
    $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });

  });
	  function getProPlotProId(proCode){
		var $ = layui.$
	  	,form = layui.form
			//获取省份下的所有城市
			$.ajax({
				type : "POST", //提交方式
				url : "${ctx}/proPlot/getProPlotProId",//路径
				data : {
					"proCode" :proCode
				},//数据，这里使用的是Json格式进行传输
				success : function(result) {//返回数据根据结果进行相应的处理
					if(result.flag==true){
						var strBuffer = "";
						strBuffer+= '<option value="">请选择</option>';
						layui.$.each(result.proList, function(i,item){
							if(item.proCode != null && item.proName != null){
								strBuffer+= '<option value='+item.proCode;
								if(proCode!=undefined&&proCode==item.proCode){
									strBuffer+= ' selected';
								}
								strBuffer+= '>'+item.proCode+'</option>';
							}
				        });
						$('#query-select-proId').append(strBuffer);
						form.render();
					}else{
						layer.msg('数据通信异常~',{icon: 0});
					}
				}
			});
		}
  </script>
</body>
</html>
